MPRI course 2-4-2 “Functional programming languages” Answers to the exercises
نویسنده
چکیده
class Closure { abstract Object apply(Object arg); Object apply2(Object arg1, Object arg2) { return ((Closure)(apply(arg1))).apply(arg2); } } abstract class Closure2 extends Closure { Object apply(Object arg) { return new PartialApplication(this, arg); } abstract Object apply2(Object arg1, Object arg2); } class PartialApplication extends Closure { Closure2 fn; Object arg1; PartialApplication(Closure2 fn, Object arg1) { this.fn = fn; this.arg1 = arg1; } Object apply(Object arg2) { return fn.apply2(arg1, arg2); } } Now, the class generated for a two-argument function λx.λy.a of free variables x1, . . . , xn is class Cλx.λy.a extends Closure2 { Object x1; ...; Object xn; Cλx.λy.a(Object x1, ..., Object xn) { this.x1 = x1; ...; this.xn = xn; } Object apply2(Object x, Object y) { return [[a]]; } } The class generated for a one-argument function λx.a of free variables x1, . . . , xn is class Cλx.λy.a extends Closure { Object x1; ...; Object xn; Cλx.a(Object x1, ..., Object xn) { this.x1 = x1; ...; this.xn = xn; } Object apply(Object x) { return [[a]]; } }
منابع مشابه
MPRI course 2-4 “Functional programming languages” Answers to the exercises
class Closure { abstract Object apply(Object arg); Object apply2(Object arg1, Object arg2) { return ((Closure)(apply(arg1))).apply(arg2); } } abstract class Closure2 extends Closure { Object apply(Object arg) { return new PartialApplication(this, arg); } abstract Object apply2(Object arg1, Object arg2); } class PartialApplication extends Closure { Closure2 fn; Object arg1;
متن کاملFunctional Programming in a Basic Database Course1
This paper describes why and how a functional programming language was used in an introductory database course. The purpose of the programming exercises in this course is to give students a better understanding of the internal structure and use of databases and database management systems. We used a functional language for its high level of abstraction and the automatic memory management which ...
متن کاملFunctional Programming - Crossing The Chasm?
Once again the computing community is coming to appreciate the expressive power of functional programming (FP) [1, 2]. Technical gatherings are buzzing with talk and, of course, debates about Haskell, Lisp/Scheme, Erlang and their younger hybrid cousins O’Caml, Scala, F# and Clojure. At the same time, popular OO languages Java and C# are being extended to support functional constructs with even...
متن کاملTemporal logics
These notes have been written as a support for the course about temporal logics taught at MPRI (Master Parisien de Recherche en Informatique) during the first semester of year 2006-2007. They contain most of what will be studied during the course, most often with detailled proofs, and several exercises, ranked from easy ( ) to hard ( ).
متن کاملDeclarative Debugging of Missing Answers in Constraint Functional-Logic Programming
It is well known that constraint logic and functional-logic programming languages have many advantages, and there is a growing trend to develop and incorporate effective tools to this class of declarative languages. In particular, debugging tools are a practical need for diagnosing the causes of erroneous computations. Recently [1], we have presented a prototype tool for the declarative diagnos...
متن کامل